package cn.qyd.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author 邱运铎
 * 模拟一些异步任务的处理
 * @date 2024-03-23 0:24
 */
public class AsynchronousTaskProcessor {
    private final static ExecutorService exec = Executors.newCachedThreadPool();

    public static void main(String[] args) throws InterruptedException {
        exec.execute(() -> {
            System.out.println("Async task started ");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Async task is completed ");
        });
        Thread.sleep(10);
        System.out.println("Main thread continues to exec other operations ");
        exec.shutdown();
    }
}
